package internal

import "os"

// JoinFiles takes a list of file paths and returns a single string containing the contents of all files
func JoinFiles(files []string) (string, error) {
	text := ""
	// loop through each file in the list
	for _, file := range files {
		// read the contents of the file
		fileText, err := os.ReadFile(file)

		// if an error occurs, return the error
		if err != nil {
			return "", err
		}

		// add the contents of the file to the text string
		text += string(fileText) + "\n"
	}

	// return the text string
	return text, nil
}
